package instant.news7;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.iqraaonline.userss.new_userss.databinding.ActivityReadBinding;

public class ReadActivity extends AppCompatActivity {

    ActivityReadBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityReadBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        ThemeClass.applyTheme(this);

        binding.backImg.setOnClickListener(v -> {
            onBackPressed();
        });


        String idenT = getIntent().getStringExtra("intent");

        if(idenT.equals("10")){
            showChapterOne();
        }else if(idenT.equals("20")){

            showChapterTwo();
        }else if(idenT.equals("30")){
            showChapterThree();
        }else if(idenT.equals("60")){
            showAIQuestions();
        }else if(idenT.equals("70")){
            showPythonQuestions();
        } else if (idenT.equals("90")) {
            showIoTQuestions();
        }


    }// OnCreate Bundle end hre
    private void showChapterOne() {
        // Build all the content for Chapter One
        StringBuilder content = new StringBuilder();

        content.append("**Chapter 1: How to Start Learning Gaming**\n\n");
        content.append("Gaming has become a global phenomenon, and learning how to create games is an exciting journey. Here are the steps to get started:\n\n");
        content.append("1. **Understand the Basics of Gaming**:\n");
        content.append("   Before diving into game development, explore different genres of games like action, adventure, puzzle, and simulation. Understand what makes a game engaging and fun. Study the psychology behind gaming and why players enjoy certain types of games.\n\n");
        content.append("2. **Learn About Game Engines**:\n");
        content.append("   Popular game engines like Unity, Unreal Engine, and Godot provide the tools to design and develop games. Start by choosing a beginner-friendly engine like Unity. Explore their documentation, and experiment with basic features like scene creation and physics.\n\n");
        content.append("3. **Start with Tutorials**:\n");
        content.append("   Online platforms like YouTube, Udemy, and free courses from Unity Learn are great for beginners. Follow tutorials to create small projects like a 2D platformer or a simple racing game. Participate in game jams to challenge your skills.\n\n");
        content.append("4. **Practice Regularly**:\n");
        content.append("   Dedicate time daily to practice and experiment with game development tools and features. Document your progress and reflect on what you learn to improve.\n\n");
        content.append("5. **Join a Community**:\n");
        content.append("   Participate in game development communities like Reddit, Discord, or local meetups to share knowledge and get feedback. Collaborate with other beginners or join existing teams to gain hands-on experience.\n\n");

        binding.faqTextView.setText(content.toString());
    }

    private void showChapterTwo() {
        // Build all the content for Chapter Two
        StringBuilder content = new StringBuilder();

        content.append("**Chapter 2: Languages and Tools for Game Development**\n\n");
        content.append("To create games, you need to learn programming languages and use design tools effectively. Here’s what you need:\n\n");
        content.append("1. **Programming Languages**:\n");
        content.append("   - **C#**: Used with Unity, it’s beginner-friendly and widely used for 2D and 3D games.\n");
        content.append("   - **C++**: Preferred for Unreal Engine, it offers high performance for complex games.\n");
        content.append("   - **JavaScript**: Essential for web-based games using frameworks like Phaser.\n");
        content.append("   - **Python**: Useful for prototyping or creating simple games using libraries like Pygame.\n\n");
        content.append("2. **Game Design Tools**:\n");
        content.append("   - **Unity**: Great for both 2D and 3D games, with extensive documentation and tutorials.\n");
        content.append("   - **Unreal Engine**: Ideal for high-quality graphics and larger projects.\n");
        content.append("   - **Godot**: Open-source and beginner-friendly for smaller projects.\n");
        content.append("   - **Construct**: No-coding tool for beginners to create 2D games quickly.\n\n");
        content.append("3. **Graphics and Sound Design**:\n");
        content.append("   - Use tools like Blender or Maya for 3D modeling.\n");
        content.append("   - Tools like Adobe Photoshop, GIMP, or Canva are great for creating 2D assets.\n");
        content.append("   - Audacity or GarageBand can help you create and edit sound effects.\n");
        content.append("   - Asset marketplaces like Unity Asset Store or FreeSound.org provide pre-made assets.\n\n");
        content.append("4. **Version Control**:\n");
        content.append("   - Learn Git to manage your code and collaborate with others on game projects. Platforms like GitHub or GitLab are great for version control.\n\n");

        binding.faqTextView.setText(content.toString());
    }

    private void showChapterThree() {
        // Build all the content for Chapter Three
        StringBuilder content = new StringBuilder();

        content.append("**Chapter 3: Designing and Implementing Games**\n\n");
        content.append("Designing a game requires creativity and structured planning. Here are steps to implement your ideas:\n\n");
        content.append("1. **Create a Game Design Document (GDD)**:\n");
        content.append("   - Write down your game concept, objectives, mechanics, storylines, and target audience.\n");
        content.append("   - Include details about the characters, levels, and gameplay flow.\n");
        content.append("   - Break your project into milestones to track progress effectively.\n\n");
        content.append("2. **Prototype Your Game**:\n");
        content.append("   - Start with a basic version of your game to test the core mechanics.\n");
        content.append("   - Use placeholders for graphics and focus on functionality.\n");
        content.append("   - Experiment with different mechanics to determine what works best.\n\n");
        content.append("3. **Iterate and Improve**:\n");
        content.append("   - Playtest your game to find bugs and gather feedback.\n");
        content.append("   - Refine your game by improving the graphics, sound, and gameplay.\n");
        content.append("   - Analyze playtest data to understand player behavior and make necessary adjustments.\n\n");
        content.append("4. **Implement Features**:\n");
        content.append("   - Add unique features like leaderboards, multiplayer modes, or achievements to enhance the experience.\n");
        content.append("   - Optimize performance to ensure smooth gameplay on different devices.\n\n");
        content.append("5. **Publish Your Game**:\n");
        content.append("   - Test your game thoroughly on different devices to ensure compatibility.\n");
        content.append("   - Publish on platforms like Google Play Store, Steam, or itch.io.\n");
        content.append("   - Develop a marketing plan to reach your target audience through social media, forums, and game review sites.\n\n");

        binding.faqTextView.setText(content.toString());
    }


    private void showAIQuestions() {
        // Build all the content
        StringBuilder content = new StringBuilder();

        content.append("**Artificial Intelligence Questions**\n\n");

        content.append("1. What is Artificial Intelligence (AI)?\n");
        content.append("   Answer: AI is the simulation of human intelligence in machines that are programmed to think and learn like humans.\n\n");

        content.append("2. Which of the following is an example of AI technology?\n");
        content.append("   Answer: Machine learning\n\n");

        content.append("3. What is Machine Learning?\n");
        content.append("   Answer: A subset of AI where systems can learn from data and improve over time without being explicitly programmed.\n\n");

        content.append("4. What does NLP stand for in AI?\n");
        content.append("   Answer: Natural Language Processing\n\n");

        content.append("5. What is the Turing Test used for?\n");
        content.append("   Answer: To determine whether a machine can exhibit intelligent behavior equivalent to or indistinguishable from that of a human.\n\n");

        content.append("6. Which type of AI model is used for image recognition?\n");
        content.append("   Answer: Convolutional Neural Networks (CNN)\n\n");

        content.append("7. What is Deep Learning?\n");
        content.append("   Answer: A subset of machine learning where neural networks with many layers learn from large amounts of data.\n\n");

        content.append("8. What is a neural network in AI?\n");
        content.append("   Answer: A computational model inspired by the way biological neural networks in the brain process information.\n\n");

        content.append("9. What is Reinforcement Learning?\n");
        content.append("   Answer: A type of machine learning where an agent learns by interacting with its environment and receiving feedback in the form of rewards or penalties.\n\n");

        content.append("10. Which of the following is used for supervised learning?\n");
        content.append("    Answer: Labeled data\n\n");

        content.append("11. What is the primary function of an AI agent?\n");
        content.append("    Answer: To perceive the environment, reason, and take actions to achieve a goal.\n\n");

        content.append("12. What is the difference between narrow AI and general AI?\n");
        content.append("    Answer: Narrow AI is specialized in one task, while general AI can perform any cognitive function a human can.\n\n");

        content.append("13. Which algorithm is commonly used in supervised learning for classification tasks?\n");
        content.append("    Answer: Decision Tree\n\n");

        content.append("14. What is the purpose of a loss function in machine learning?\n");
        content.append("    Answer: To measure the difference between the model's prediction and the actual outcome.\n\n");

        content.append("15. What is overfitting in machine learning?\n");
        content.append("    Answer: When a model learns the details and noise in the training data to the extent that it negatively impacts its performance on new data.\n\n");

        content.append("16. What is an example of unsupervised learning?\n");
        content.append("    Answer: Clustering algorithms like K-means\n\n");

        content.append("17. What does the term 'training data' refer to in machine learning?\n");
        content.append("    Answer: The data used to train a machine learning model, where the correct answer is known.\n\n");

        content.append("18. Which AI technique is used to generate recommendations for users?\n");
        content.append("    Answer: Recommender systems\n\n");

        content.append("19. What is the purpose of the backpropagation algorithm in neural networks?\n");
        content.append("    Answer: To update the weights in a neural network by calculating the gradient of the loss function.\n\n");

        content.append("20. What is the difference between AI and automation?\n");
        content.append("    Answer: AI involves machines learning and making decisions, while automation refers to machines performing tasks without decision-making.\n\n");

        // Set the content to the TextView
        binding.faqTextView.setText(content.toString());
    }


    private void showPythonQuestions() {
        // Build all the content
        StringBuilder content = new StringBuilder();

        content.append("**Python Programming Questions**\n\n");

        content.append("1. What is the correct way to declare a variable in Python?\n");
        content.append("   Answer: x = 10\n\n");

        content.append("2. Which of the following is used to create a list in Python?\n");
        content.append("   Answer: list = [1, 2, 3]\n\n");

        content.append("3. How do you start a comment in Python?\n");
        content.append("   Answer: # This is a comment\n\n");

        content.append("4. What is the output of the following code: print(2 + 3 * 4)?\n");
        content.append("   Answer: 14\n\n");

        content.append("5. Which of the following is a mutable data type in Python?\n");
        content.append("   Answer: list\n\n");

        content.append("6. How do you declare a function in Python?\n");
        content.append("   Answer: def function_name():\n\n");

        content.append("7. What is the result of the expression 3 / 2 in Python?\n");
        content.append("   Answer: 1.5\n\n");

        content.append("8. How do you create a dictionary in Python?\n");
        content.append("   Answer: dict = {'key': 'value'}\n\n");

        content.append("9. Which of the following functions is used to get the length of a list in Python?\n");
        content.append("   Answer: len()\n\n");

        content.append("10. How do you handle exceptions in Python?\n");
        content.append("    Answer: try/except\n\n");

        content.append("11. Which method is used to add an item to the end of a list?\n");
        content.append("    Answer: list.append(item)\n\n");

        content.append("12. How do you open a file in Python for reading?\n");
        content.append("    Answer: open('filename', 'r')\n\n");

        content.append("13. What does the 'self' keyword represent in a Python class?\n");
        content.append("    Answer: It represents the instance of the class.\n\n");

        content.append("14. Which function is used to convert a string to a list in Python?\n");
        content.append("    Answer: list()\n\n");

        content.append("15. What is the output of the following code: print(bool('False'))?\n");
        content.append("    Answer: True\n\n");

        content.append("16. How can you check the type of a variable in Python?\n");
        content.append("    Answer: type(variable)\n\n");

        content.append("17. Which of the following is used to create an empty tuple in Python?\n");
        content.append("    Answer: tuple = ()\n\n");

        content.append("18. How do you import a module in Python?\n");
        content.append("    Answer: import module_name\n\n");

        content.append("19. What is a lambda function in Python?\n");
        content.append("    Answer: A small anonymous function defined with the 'lambda' keyword\n\n");

        content.append("20. Which of the following is used to remove an item from a list in Python?\n");
        content.append("    Answer: list.remove(item)\n\n");

        // Set the content to the TextView
        binding.faqTextView.setText(content.toString());
    }


    private void showIoTQuestions() {
        // Build all the content
        StringBuilder content = new StringBuilder();

        content.append("**Internet of Things (IoT) Questions**\n\n");

        content.append("1. What is the Internet of Things (IoT)?\n");
        content.append("   Answer: IoT refers to the connection of everyday devices to the internet, allowing them to collect, send, and receive data.\n\n");

        content.append("2. Which of the following is an example of an IoT device?\n");
        content.append("   Answer: Smart thermostat\n\n");

        content.append("3. What is the primary purpose of IoT?\n");
        content.append("   Answer: To improve the efficiency and automation of various systems by enabling devices to communicate and act on data.\n\n");

        content.append("4. What is a smart home in IoT?\n");
        content.append("   Answer: A home equipped with IoT devices that allow remote management and monitoring of appliances and systems like lighting, security, and temperature.\n\n");

        content.append("5. What protocol is commonly used in IoT networks for communication?\n");
        content.append("   Answer: MQTT (Message Queuing Telemetry Transport)\n\n");

        content.append("6. What is the difference between IoT and traditional devices?\n");
        content.append("   Answer: IoT devices are connected to the internet and can communicate with other devices, while traditional devices operate independently.\n\n");

        content.append("7. What is a sensor in an IoT system?\n");
        content.append("   Answer: A device that detects and measures physical properties such as temperature, humidity, motion, etc., and sends the data to other devices.\n\n");

        content.append("8. What is edge computing in IoT?\n");
        content.append("   Answer: Edge computing refers to processing data near the source of data generation, such as on a local IoT device, to reduce latency and bandwidth usage.\n\n");

        content.append("9. What does a gateway do in an IoT system?\n");
        content.append("   Answer: A gateway acts as a bridge between IoT devices and external networks, enabling communication between devices and the internet.\n\n");

        content.append("10. What are the security concerns related to IoT devices?\n");
        content.append("    Answer: Privacy, unauthorized access, data breaches, and the risk of malicious attacks are major security concerns.\n\n");

        content.append("11. Which of the following is an IoT application in healthcare?\n");
        content.append("    Answer: Remote patient monitoring\n\n");

        content.append("12. What is the role of cloud computing in IoT?\n");
        content.append("    Answer: Cloud computing provides scalable storage and computing resources for processing and analyzing IoT data.\n\n");

        content.append("13. What is the term 'Smart City' in IoT?\n");
        content.append("    Answer: A smart city uses IoT technologies to manage urban resources such as traffic, waste, and energy for improved efficiency and quality of life.\n\n");

        content.append("14. What is the most common communication protocol for IoT devices?\n");
        content.append("    Answer: Wi-Fi\n\n");

        content.append("15. What is the role of Artificial Intelligence in IoT?\n");
        content.append("    Answer: AI helps IoT devices make intelligent decisions based on data analysis and improves automation in IoT systems.\n\n");

        content.append("16. What is a smart thermostat?\n");
        content.append("    Answer: A thermostat that can be controlled remotely via the internet and adjusts home temperature based on user preferences and schedules.\n\n");

        content.append("17. Which of the following is NOT an IoT device?\n");
        content.append("    Answer: A traditional microwave oven\n\n");

        content.append("18. What is the Internet of Medical Things (IoMT)?\n");
        content.append("    Answer: A network of medical devices that connect to the internet to monitor, collect, and analyze patient health data.\n\n");

        content.append("19. What is the term 'IoT ecosystem'?\n");
        content.append("    Answer: The IoT ecosystem refers to the network of devices, communication protocols, platforms, and users that interact with IoT systems.\n\n");

        content.append("20. What is the impact of IoT on manufacturing?\n");
        content.append("    Answer: IoT improves manufacturing by enabling predictive maintenance, real-time monitoring, and optimization of production processes.\n\n");

        // Set the content to the TextView
        binding.faqTextView.setText(content.toString());
    }


}